<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<html>
<head>
<title>发布信息</title>

<link href="css/addGoods.css" rel="stylesheet" type="text/css" />

<script src="js/jquery-3.1.0.min.js"></script>

<script>
  
	$(document).ready(function() {
		$("#de").click(function() {
			var count = $("#count").text() - 1;
			if(count<=0){
			    count=0;
			}
			$("#count").text(count);
		});
		$("#ad").click(function() {
			var count = $("#count").text()*1 + 1*1;
			$("#count").text(count);
			var post = 'addBuyGood.action?good.listType=buy&good.state=1&good.count='+count;
			$("#mss").attr("action",post);
		});
	
	$("#name").blur(function() {
			var name = $("#name").val();
			var checkName = /[\u4e00\u9fa5\a-zA-Z0-9]{4,12}/;
			if(checkName.test(name)==false){
			    var errorMsg = "输入名称不符合要求";
			    $("#ms1").text(errorMsg);
			}else{
			   var rightMsg = "符合要求";
			   $("#ms1").text(rightMsg);
			}
		});
	$("#detail").blur(function(){
	      var detail = $("#detail").val();
	      var checkDetail=/[\u4e00-\u9fa5，。！、……a-zA-Z\d]{30,300}/;
	      if(checkDetail.test(detail)==false){
			    var errorMsg = "输入名称不符合要求";
			    $("#ms2").text(errorMsg);
			}else{
			   var rightMsg = "符合要求";
			   $("#ms2").text(rightMsg);
			}
	});
	$("#price").blur(function(){
	      var price = $("#price").val();
	      var checkPrice=/^(0|[1-9][0-9]{0,9})(\.[0-9]{1,2})?$/;
	      if(checkPrice.test(price)==false){
			    var errorMsg = "输入名称不符合要求";
			    $("#ms3").text(errorMsg);
			}else{
			   var rightMsg = "符合要求";
			   $("#ms3").text(rightMsg);
			}
	});
	
	$("#type2").click(function() {
			$("#ms1").text(" ");
			$("#ms2").text(" ");
			$("#ms3").text(" ");
			$("#count").text(0);
		});
		
	$("#types").change(function(){
	     var type = $(this).val();
	     action = 'addGood.action?type='+type;
	     $("#mss").attr("action",action);  
	});
  });
</script>



</head>
<body>
</head>
<body>
	<div id="main">
		<div class="box1">
		   <h2 style="position:block;margin-left:16%">我要发布</h2>
			<div class="show">
			   <h4>填写求购物品的详细信息：</h4>
				<form action="" method="post" id="mss">
				<table border="0">
					<tr>
						<td>物品的名称：</td>
						<td><input type="text" name="good.goodName" placeholder="中文，英文，数字  4-12长度" id="name"/><span id="ms1"></span>
						</td>
					</tr>
					<tr>
						<td>类&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;型：</td>
						<td><select name="good.type" id="types">
								<option value=1>电子产品</option>
								<option value=2>服装服饰</option>
								<option value=3>美妆饰品</option>
								<option value=4>食品饮料</option>
								<option value=5>婴幼用品</option>
								<option value=6>文学著作</option>
						</select></td>
					</tr>
					<tr></tr>
					<tr> 
						<td>数&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;量：</td>
						<td  style="vertical-align:top;">
						   <a id="de"><img src="img/de.png"></a>
						   <span style="font-size:22px;margin-bottom:15px;" id="count">0</span>
						   <a id="ad"><img src="img/ad.png"></a>
						</td>
					</tr>
					<tr></tr>
					<tr>
						<td style="vertical-align:top;">详 细 描 述：</td>
						<td><textarea rows="10" cols="60" name="good.briefing" id="detail" placeholder="中文，英文，数字，标点  30-300长度"></textarea>
						<br/><br/><span id="ms2"></span>
						</td>
					</tr>
					<tr></tr>
					<tr>
						<td>估&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;价：</td>
						<td><input type="text" name="good.price" id="price" placeholder="数字，小数点，最多两位小数   不能为负"/>  RMB
						<span id="ms3"></span>
						</td>
					</tr>
					<tr></tr>
					<tr>
					    <td></td>
						<td><input type="submit" value="发            布" id="type1" style="width:30%"/>
						<input type="reset" value="重            置  " id="type2"style="width:30%"/></td>
					</tr>
				</table>
				</form>
			</div>
		</div>
	</div>
</body>
</html>